home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -websites- / haage&partner / ftp / classx / fm3-demo.lha / FM3-DEMO / Rexx / AnimTextGif.rexx < prev    next >
OS/2 REXX Batch file  |  1997-10-21  |  6KB  |  251 lines

  1. /******************************************************************/
  2. /* ClassX Amiga Rexx script - Copyright © 1997 ClassX Development */
  3. /******************************************************************/
  4.  
  5. /*
  6.     $VER: AnimTextGif.rexx 3.1
  7. */
  8.  
  9. /*
  10. #ITA "Animazione Testo (GIF Anim)"
  11. #INF "Crea un testo animato in formato GIF-Anim."
  12. #INF "- Descrizione:"
  13. #INF "  La funzione genera un testo animato in formato GIF-Anim agendo"
  14. #INF "  sui settaggi e le tessiture attribuite al font. Almeno una delle"
  15. #INF "  tessiture deve essere composta da più fotogrammi."
  16. #INF "- Uso:"
  17. #INF "  Dopo aver impostato correttamente l'aspetto del font è sufficiente"
  18. #INF "  seguire le istruzioni a video rispondendo alle richieste del"
  19. #INF "  programma."
  20. #END
  21. */
  22.  
  23. /*
  24. #ENG "Anim Text (GIF-Anim)"
  25. #INF "Create an animated text in GIF-Anim format."
  26. #INF "- Description:"
  27. #INF "  This function generates an animated text in GIF-Anim format,"
  28. #INF "  working with the settings and the textures applied to the font."
  29. #INF "  At least one of the textures must have more than one frame."
  30. #INF "- Usage:"
  31. #INF "  Simply follow the instructions on screen and answer the questions"
  32. #INF "  which will be asked by the program."
  33. #END
  34. */
  35.  
  36.  
  37. MYPORT = 'FontMachine'
  38.  
  39. IF ~SHOW('P', MYPORT) THEN DO
  40.     IF EXISTS('FontMachine:FontMachine') THEN DO
  41.         ADDRESS COMMAND 'Run >NIL: FontMachine:FontMachine'
  42.         DO 30 WHILE ~SHOW('P',MYPORT)
  43.              ADDRESS COMMAND 'Wait >NIL: 1 SEC'
  44.         END
  45.     END
  46.     ELSE DO
  47.         SAY "FontMachine could not be loaded."
  48.         EXIT 10
  49.     END
  50. END
  51.  
  52. IF ~SHOW('P', MYPORT) THEN DO
  53.     SAY 'FontMachine Rexx port could not be opened.'
  54.     EXIT 10
  55. END
  56.  
  57. ADDRESS VALUE MYPORT
  58. OPTIONS RESULTS
  59. OPTIONS FAILAT 10000
  60.  
  61. /* Make sure rexxsupport library is opened */
  62. IF ~SHOW('L','rexxsupport.library') THEN CALL ADDLIB('rexxsupport.library',0,-30)
  63.  
  64. SIGNAL ON Break_C
  65. SIGNAL ON Break_D
  66.  
  67. /******************************************************************/
  68.  
  69. /* check font */
  70.  
  71. GetPrevWinAddress
  72. if FM_RESULT = 0 then EXIT 0
  73.  
  74. /* local vars//settings */
  75.  
  76. FRAMEPATH = "FontMachine:T/frame"
  77. ANIMPATH  = "FontMachine:AnimText/"
  78.  
  79.  
  80. /* language support */
  81.  
  82. LockGui
  83. GetLocale
  84.  
  85. Select 
  86.     /* italiano */
  87.     when FM_RESULT = "ITA" then do
  88.         TXT_01 = '"Digita il testo da animare"'
  89.         TXT_02 = '"Seleziona la tessitura da animare"'
  90.         TXT_03 = '"Fronte|Bordo|Fronte+Bordo|Cancel"'
  91.         TXT_04 = '"Salva Animazione"'
  92.         TXT_05 = '"Quanti fotogrammi di animazione ?"'
  93.         TXT_06 = '"Errore di creazione GIF-Anim"'
  94.         TXT_10 = '"Fine"'
  95.     end
  96.  
  97.     /* english or default language */
  98.     when FM_RESULT = "ENG" then do
  99.         TXT_01 = '"Type the text to animate"'
  100.         TXT_02 = '"Select the texture to animate"'
  101.         TXT_03 = '"Front|Border|Front+Border|Cancel"'
  102.         TXT_04 = '"Save the Animation"'
  103.         TXT_05 = '"How many frames for the AnimText ?"'
  104.         TXT_06 = '"GIF-Anim creation error"'
  105.         TXT_10 = '"End"'
  106.     end
  107. end
  108.  
  109.  
  110. /* get texture information */
  111. GetTextureFrames FRONT
  112. fframes = FM_RESULT
  113. GetTextureFrames BORDER
  114. bframes = FM_RESULT
  115.  
  116. if (fframes > 1) | (bframes > 1) then do
  117.  
  118.     /* store environment */
  119.     GetPref AUTODRAW
  120.     pref_autodraw = FM_RESULT
  121.     GetPreviewString
  122.     pref_previewstring = FM_RESULT
  123.  
  124.     /* set new environment */
  125.     SetPref AUTODRAW ON
  126.     SetPreviewString '" "'
  127.     call WaitRender
  128.  
  129.     /* cleanup frame path */
  130.     ADDRESS COMMAND 'Delete >NIL: "'FRAMEPATH'#?"'
  131.     ADDRESS COMMAND 'Delete >NIL: FontMachine:t/frm.lst'
  132.  
  133.     AskString '"AnimText"' TXT_01 '"'pref_previewstring'"'
  134.     if FM_RESULT ~= '' then do
  135.         previewstring = FM_RESULT
  136.         SetPreviewString '"'FM_RESULT'"'
  137.         CALL WaitRender
  138.  
  139.         Request '"FontMachine"' TXT_02 TXT_03
  140.         sel = FM_RESULT
  141.     
  142.         Select
  143.             /* Front */
  144.             when sel = 1 then do
  145.                 do f=1 to fframes
  146.                     LoadTextureFrame FRONT f
  147.                     CALL WaitRender
  148.                     SavePreview '"'FRAMEPATH || "." || RIGHT(f, 3, "0")'"'
  149.                     if RC ~= 0 then do
  150.                         Request '"FontMachine"' '"'FM_ERROR'"' '"Ok"'
  151.                         break
  152.                     end
  153.                 end
  154.             end
  155.  
  156.             /* Border */
  157.             when sel = 2 then do
  158.                 do f=1 to bframes
  159.                     LoadTextureFrame BORDER f
  160.                     CALL WaitRender
  161.                     SavePreview '"'FRAMEPATH || "." || RIGHT(f, 3, "0")'"'
  162.                     if RC ~= 0 then do
  163.                         Request '"FontMachine"' '"'FM_ERROR'"' '"Ok"'
  164.                         break
  165.                     end
  166.                 end
  167.             end
  168.  
  169.             /* Front+Border */
  170.             when sel = 3 then do
  171.                 totframes = MAX(fframes,bframes)
  172.                 AskString '"AnimText"' TXT_05  totframes
  173.                 if FM_RESULT ~= 0 then totframes = FM_RESULT
  174.  
  175.                 do f=1 to totframes
  176.                     LoadTextureFrame FRONT f
  177.                     LoadTextureFrame BORDER f
  178.                     CALL WaitRender
  179.                     SavePreview '"'FRAMEPATH || "." || RIGHT(f, 3, "0")'"'
  180.                     if RC ~= 0 then do
  181.                         Request '"FontMachine"' '"'FM_ERROR'"' '"Ok"'
  182.                         break
  183.                     end
  184.                 end
  185.             end
  186.  
  187.             /* cancel -> do nothing */
  188.             otherwise nop
  189.         end
  190.  
  191.         if sel ~= 0 then do
  192.             /* convert IFF frames to GIF */
  193.             ADDRESS COMMAND 'List >FontMachine:t/frm.lst "'FRAMEPATH'#?" FILES LFORMAT "FontMachine:c/TapGIF %p%n %p%n.GIF BACK 0 TRAN 0"'
  194.             ADDRESS COMMAND 'Execute >NIL: FontMachine:t/frm.lst'
  195.             if RC = 0 then do
  196.                 /* convert to GIF animation */
  197.                 RequestFile TXT_04 '"'ANIMPATH || previewstring || ".gif"'"' SAVEMODE
  198.                 ANIMPATH = FM_RESULT
  199.                 if ANIMPATH ~= "" then do
  200.                     /* build GIF framelist */
  201.                     ADDRESS COMMAND 'List >FontMachine:t/frm.lst "'FRAMEPATH'#?.GIF" FILES LFORMAT "%p%n"'
  202.                     ADDRESS COMMAND 'Sort FontMachine:t/frm.lst FontMachine:t/frm.lst'
  203.                     /* make the GIF-Anim */
  204.                     ADDRESS COMMAND 'FontMachine:c/WhirlGif >NIL: -o "'ANIMPATH'" -loop -time 10 -disp back -trans 0 -i FontMachine:t/frm.lst'
  205.                 end
  206.             end
  207.             else do
  208.                 Request '"FontMachine"' TXT_06 'Ok'
  209.             end
  210.  
  211.             /* cleanup frame path */
  212.             ADDRESS COMMAND 'Delete >NIL: "'FRAMEPATH'#?"'
  213.             ADDRESS COMMAND 'Delete >NIL: FontMachine:t/frm.lst'
  214.         end
  215.     end
  216.     /* restore environment */
  217.     LoadTextureFrame BORDER 1
  218.     LoadTextureFrame FRONT 1
  219.     SetPref AUTODRAW pref_autodraw
  220.     SetPreviewString '"'pref_previewstring'"'
  221.     CALL WaitRender
  222.  
  223. end
  224.  
  225. /* end */
  226. Request '"FontMachine"' TXT_10 'Ok'
  227. UnLockGui
  228. EXIT
  229.  
  230. /******************************************************************/
  231.  
  232. WaitRender: PROCEDURE
  233.     /* wait the rendering of the font */
  234.     DO FOREVER
  235.         CheckRedraw
  236.         if FM_RESULT ~= 0 then ADDRESS COMMAND 'Wait >NIL: 1 SEC'
  237.         else LEAVE
  238.     END
  239. RETURN
  240.  
  241. /******************************************************************/
  242.  
  243. /* break handlers */
  244. Break_C:
  245. Break_D:
  246.     UnLockGui
  247.     Request '"FontMachine"' '"Procedure Stopped"' 'Ok'
  248. RETURN
  249.  
  250. /******************************************************************/
  251.